package com.yy.zhbootgateway;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述:
 *
 * @author: yanglin
 * @Date: 2021-11-13-11:03
 * @Version: 1.0
 */
@Slf4j
public class RunTest {

    public static void main(String[] args) {
        String d2 = "2021-11-09 15:40:34";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String d1 = "3921-12-09 03:40:34.0";
        try {
            System.out.println(sdf.parse(d1));
            System.out.println(sdf.parse(d2));
        } catch (ParseException e) {
            e.printStackTrace();
        }

        String dateStr = "2021-11-09 15:40:34";
        int year = Integer.parseInt(dateStr.substring(0, 4));
        int month = Integer.parseInt(dateStr.substring(5, 7));
        int day = Integer.parseInt(dateStr.substring(8, 10));
        int hour = Integer.parseInt(dateStr.substring(11, 13));
        int minute = Integer.parseInt(dateStr.substring(14, 16));
        int second = Integer.parseInt(dateStr.substring(17, 19));
        log.info(String.valueOf(year) + "-" + String.valueOf(month) + "-" +  String.valueOf(day) + "-" +  String.valueOf(hour) + "-" +  String.valueOf(minute) + "-" + String.valueOf(second));
        Date date = new Date(year, month, day, hour, minute, second);
        System.out.println(date);
    }
}
